#import "NewTabbarVC.h"
#import "KFCartVC.h"
#import "KFOrderVC.h"
#import "BaseNavVC.h"
#import "KFReportVC.h"
@interface NewTabbarVC ()

@end

@implementation NewTabbarVC
- (void)viewDidLoad {
    [super viewDidLoad];
    //首页
    KFCartVC * vc = [[KFCartVC alloc]init];
    vc.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"桌台" image:Image(@"桌台") selectedImage:[self backImage:Image(@"桌台sel")]];
    BaseNavVC * navVC = [[BaseNavVC alloc]initWithRootViewController:vc];

    //个人
    KFOrderVC * person  = [KFOrderVC new];
    person.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"订单" image:Image(@"订单") selectedImage:[self backImage:Image(@"订单sel")]];
    BaseNavVC * personNav = [[BaseNavVC alloc]initWithRootViewController:person];
    [[UITabBarItem appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:ThemeColor} forState:UIControlStateSelected];
    
    KFReportVC * report  = [KFReportVC new];
    report.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"报表" image:Image(@"报表") selectedImage:[self backImage:Image(@"报表sel")]];
    BaseNavVC * reportNav = [[BaseNavVC alloc]initWithRootViewController:report];
    [[UITabBarItem appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:ThemeColor} forState:UIControlStateSelected];

    self.viewControllers = @[navVC,personNav,reportNav];
    self.selectedIndex = 0;
    if (@available(iOS 13.0, *)) {
            // 创建标准外观
            UITabBarAppearance *appearance = [UITabBarAppearance new];
            
            // 配置选中状态文字属性
            [appearance.stackedLayoutAppearance.selected setTitleTextAttributes:@{
                NSForegroundColorAttributeName: [UIColor redColor], // 替换为你的颜色
                NSFontAttributeName: [UIFont systemFontOfSize:12]
            }];
            
            // 配置未选中状态文字属性（可选）
            [appearance.stackedLayoutAppearance.normal setTitleTextAttributes:@{
                NSForegroundColorAttributeName: [UIColor grayColor],
                NSFontAttributeName: [UIFont systemFontOfSize:12]
            }];
            
            // 应用配置到所有TabBar
            [UITabBar appearance].standardAppearance = appearance;
            
            // iOS 15+ 额外配置（防止滚动时失效）
            if (@available(iOS 15.0, *)) {
                [UITabBar appearance].scrollEdgeAppearance = appearance;
            }
        } else {
            // iOS 13以下旧方案
            [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor redColor]}
                                                    forState:UIControlStateSelected];
        }
}


-(UIImage*)backImage:(UIImage*)image{
    return  [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
